package com.usf.jprovider.schema.provider.pointer;

import javax.xml.bind.annotation.XmlSeeAlso;

import com.usf.jprovider.exception.FieldNotFoundException;
import com.usf.jprovider.object.JObjectNode;
import com.usf.jprovider.object.env.Environment;
import com.usf.jprovider.object.type.JType;
import com.usf.jprovider.schema.provider.AbstractProvider;
import com.usf.jprovider.schema.provider.pointer.dynamic.AbstractDynamicPointer;

@XmlSeeAlso({
	AbstractDynamicPointer.class,
	CurrentPointer.class
})
public abstract class AbstractPointer extends AbstractProvider {
	
	protected AbstractPointer() {
		super();
	}
	
	@Override
	public final JType<?> create(Environment env, JObjectNode node) throws FieldNotFoundException {
		return pointedValue(node);
	}
	@Override
	public final boolean checkValue(Environment env, JObjectNode node, JType<?> value) throws FieldNotFoundException {
		return pointedValue(node).equals(value);
	}
	
	protected abstract JType<?> pointedValue(JObjectNode node) throws FieldNotFoundException;
}
